home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Nebula 1
/
Nebula One.iso
/
Utilities
/
Converters
/
Convert_PICT
/
Source
/
CommentedPSCode
/
Common
< prev
next >
Wrap
Text File
|
1995-06-12
|
7KB
|
347 lines
/COPYING_INFO
(
Created by Convert PICT a PICT to eps converter.
Copyright (C) 1993 David John Burrowes
The following PS routines are distributed under terms of GNU General Public License.
See any copy of the GPL for more info. E.g. in COPYING in Convert PICT's online help.
)
def
%BEGIN Common
%
% Pen size
%
/penWidth 1 def
/penHeight 1 def
%
% The coordinates of the last rectangle used
%
/lastTop 0 def
/lastLeft 0 def
/lastBottom 0 def
/lastRight 0 def
%
% Define color values
%
/foregroundColor [0 0 0] def
/backgroundColor [1 1 1] def
%
% Define the three patterns used
%
/backPattern 20 dict def
backPattern begin
/QDPatType 0 def
/QDPatData <FFFFFFFFFFFFFFFF> def % white
/QDPatGrey 1 def
end
/penPattern 20 dict def
penPattern begin
/QDPatType 0 def
/QDPatData <0000000000000000> def
/QDPatGrey 0 def
end
/fillPattern 20 dict def
fillPattern begin
/QDPatType 0 def
/QDPatData <0000000000000000> def % black
/QDPatGrey 1 def
end
%
% set the drawing mode
%
/patternMode /patCopy def
%
% Calculate the PostScript level currently in use.
%
/PSlevel
systemdict /languagelevel known
{languagelevel}
{1}
ifelse
def
%%%%%%%%%%%%%
% Name: usePattern
% Syntax: pattern usePattern -
% About: Set the current drawing patten to the one passed.
% Note: We do some weird double-use of dictionary in PS 2 code
%%%%%%%%%%%%%
/usePattern
{
/QDPatternDict exch def
/patternType QDPatternDict /QDPatType get def
patternType 2 eq
{ QDPatternDict /QDColorValue get useColor }
{
PSlevel 1 eq
{
%
% Can't do true patterns, so compute percent gray, and weight by
% appropriate ammounts of fore and back colors.
%
/patGrey QDPatternDict /QDPatGrey get def
/invGrey 1 patGrey sub def
0 1 2
{
/index exch def
foregroundColor index get invGrey mul
backgroundColor index get patGrey mul add
}
for
setrgbcolor
}
{
% PS level 2
patternType 0 eq
{
/PSPatDict 15 dict def
PSPatDict begin
/PaintType 1 def
/PatternType 1 def
/TilingType 1 def
/BBox [0 0 8 8] def
/XStep 8 def
/YStep 8 def
/myData QDPatternDict /QDPatData get def
/PaintProc {
%
% Draw foreground bits, and then draw background
% bits, using different colors depending on mode.
%
begin
patternMode /patBic eq
patternMode /notPatCopy eq
or
{ 0 1 2 { backgroundColor exch get } for }
%patOr, patCopy, and default
{ 0 1 2 { foregroundColor exch get } for }
ifelse
setrgbcolor
8 8 false
[1 0 0 1 0 0]
myData
imagemask
patternMode /notPatOr eq
patternMode /notPatCopy eq
or
{ 0 1 2 { foregroundColor exch get } for }
% patCopy, notBic and default
{ 0 1 2 { backgroundColor exch get } for }
ifelse
setrgbcolor
8 8 true
[1 0 0 1 0 0]
myData
imagemask
end
} def
end
PSPatDict matrix makepattern setpattern
}
{
% Pat type 2
/PSPatDict 20 dict def
PSPatDict begin
/PaintType 1 def
/PatternType 1 def
/TilingType 1 def
/BBox [0 0 QDPatternDict /QDDestWidth get
QDPatternDict /QDDestHeight get] def
/XStep QDPatternDict /QDDestWidth get def
/YStep QDPatternDict /QDDestHeight get def
/ImageType 1 def
/Width QDPatternDict /Width get def
/Height QDPatternDict /Height get def
/BitsPerComponent
QDPatternDict /BitsPerComponent get def
/Decode [ 0 2 BitsPerComponent exp 1 sub ] def
/ImageMatrix [1 0 0 1 0 0] def
/DataSource QDPatternDict /QDPatBitmap get def
/PaintProc {
/ourDict exch def
[/Indexed /DeviceRGB
QDPatternDict /QDNumColors get
QDPatternDict /QDColorTable get]
setcolorspace
ourDict image
} def
end
PSPatDict matrix makepattern setpattern
}
ifelse
}
ifelse
}
ifelse
}
def
%%%%%%%%%%%%%
% Name: useColor
% Syntax: [red green blue] useColor -
% About: Given array with R G B values, set the current color to it.
%%%%%%%%%%%%%
/useColor
{
/colorArray exch def
colorArray 0 get
colorArray 1 get
colorArray 2 get
setrgbcolor
}
def
%%%%%%%%%%%%%
% Name: setupForArcPath
% Syntax: width height bottom left setupForArcPath xcoord ycoord radius
% About: Given bounds of an oval defined by a rectangle, return its
% center in undistored space & it's radius (good for use with arc)
% Also, distort coord system so oval can be drawn (not as circle).
% If width is > height (computations merely mirrored if reversed)
% scale coord system, push x coord center, push y coord center as:
% (ovalBottom-(ovalHeight/2)) * (ovalWidth/ovalHeight)
% (Get center then unscale it)
%%%%%%%%%%%%%
/setupForArcPath
{
/ovalLeft exch def
/ovalBottom exch def
/ovalHeight exch def
/ovalWidth exch def
ovalHeight 0 le
ovalWidth 0 le
or
{ 0 0 0 } % if height or with <= 0, return center 0,0 radius 0
{
ovalWidth ovalHeight gt
{
1 ovalHeight ovalWidth div scale
ovalLeft ovalWidth 2 div add % X coordinate center
ovalBottom ovalHeight 2 div sub ovalWidth ovalHeight div mul
ovalWidth 2 div % radius
}
{
ovalWidth ovalHeight div 1 scale
ovalLeft ovalWidth 2 div add ovalHeight ovalWidth div mul
ovalBottom ovalHeight 2 div sub % Y coord center
ovalHeight 2 div % radius
}
ifelse
}
ifelse
}
def
%%%%%%%%%%%%%
% Name: regionBounds
% Syntax: top left bottom right regionBounds -
% About: Build a closed path given the coordinates on the stack.
%%%%%%%%%%%%%
/regionBounds
{
/right exch def
/bottom exch def
/left exch def
/top exch def
newpath
left top moveto
right top lineto
right bottom lineto
left bottom lineto
closepath
}
def
%%%%%%%%%%%%%
% Name: regionPath
% Syntax: x y ... x y n regionPath -
% About: Given N, and N pairs of x,y coords which define a region's edge,
% build a path through these coordinates.
%%%%%%%%%%%%%
/regionPath
{
/numShapes exch def
newpath
numShapes
{
/numPoints exch def
/y exch def
/x exch def
x y moveto
numPoints 1 sub
{
/y exch def
/x exch def
x y lineto
}
repeat
closepath
}
repeat
}
def
%%%%%%%%%%%%%
% Name: startPict
% Syntax: num startPict -
% About: Called before any converted pict data. Do any setup here.
%%%%%%%%%%%%%
/startPict
{pop}
def
%%%%%%%%%%%%%
% Name: QDClip [0001]
% Syntax: regionInfo QDclip -
% About: Sets the clipping path for the drawing. If shapes in region
% other than bounding rect, build their path and clip to them too.
%%%%%%%%%%%%%
/QDclip
{
initclip
regionBounds
clip
/numShapes exch def
numShapes 0 gt
{
numShapes
regionPath
clip
}
if
}
def
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% Name: endPict [00FF]
% Syntax: - endPict -
% About: Marks the end of a picture. Do any cleanup here.
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
/endPict
{}
def
%%%%%%%%%%%%%
% Name: headerOp [0C00]
% Syntax: [num num num num num num] headerOp -
% [num num num num [rect] num] header op -
% About: Two forms (former def. in IM V5, latter im V6. Args in same order listed there)
%%%%%%%%%%%%%
/headerOp
{pop}
def
%END Common